package com.zt.weibo.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.zt.weibo.WeiboApp;
import com.zt.weibo.comment.WeiboCommentActivity;
import com.zt.weibo.detail.WeiboDetailActivity;
import com.zt.weibo.login.AuthorizeActivity;
import com.zt.weibo.login.LoginActivity;
import com.zt.weibo.main.WeiboActivity;
import com.zt.weibo.vo.StatusInfo;

/**
 * 该类用于管理Activity切换
 * @author zhaotong
 */
public class SwitchActivity
{
	
	/**
	 * 退出程序
	 * @param act 当前Activity
	 */
	public static void exit(Context con)
	{
		PrintLog.debug("前往安卓HOME页面");
		Intent intent = new Intent(Intent.ACTION_MAIN);
		intent.addCategory(Intent.CATEGORY_HOME);
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		con.startActivity(intent);
		WeiboApp.exitApp();
	}
	
	/**
	 * 切换至LoginActivity
	 * @param act 当前Activity
	 */
	public static void login(Activity act)
	{
		PrintLog.debug("前往微博登陆界面");
		Intent intent = new Intent(act, LoginActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
		act.startActivity(intent);
	}
	
	/**
	 * 切换至AuthorizeActivity
	 * @param act 当前{@link Activity}
	 */
	public static void auth(Activity act, String userName)
	{
		PrintLog.debug("前往授权界面");
		Intent intent = new Intent(act, AuthorizeActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
		intent.putExtra("UserName", userName);
		act.startActivity(intent);
	}
	
	/**
	 * 切换至WeiboActivity
	 * @param act 当前Activity
	 */
	public static void weiboMain(Activity act)
	{
		PrintLog.debug("前往微博主界面");
		Intent intent = new Intent(act, WeiboActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
		act.startActivity(intent);
	}
	
	/**
	 * 切换至WeiboDetailActivity，传入StatusInfo类。
	 * @param act 当前Activity
	 * @param info StatusInfo类
	 */
	public static void weiboDetail(Activity act, StatusInfo info)
	{
		PrintLog.debug("前往微博详情界面");
		Intent intent = new Intent(act, WeiboDetailActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
		intent.putExtra("StatusInfo", info);
		act.startActivity(intent);
	}
	
	/**
	 * 切换至WeiboCommentActivity，传入StatusInfo类
	 * @param act 当前Activity
	 * @param info StatusInfo类
	 */
	public static void weiboComment(Activity act, StatusInfo info)
	{
		PrintLog.debug("前往微博评论界面");
		Intent intent = new Intent(act, WeiboCommentActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
		intent.putExtra("StatusInfo", info);
		act.startActivity(intent);
	}
	
}
